<?php

class Application_Model_User extends Application_Model_Disputeo
{

    protected $_id;
    protected $_email;
    protected $_password;
    protected $_realName;
    protected $_username;
    protected $_passwordSalt;
    protected $_passwordReset;

    public function __construct(array $options = null)
    {
        if (is_array($options)) {
            $this->setOptions($options);
        }
    }

    public function setPassword($text)
    {
        $this->_password = (string) $text;
        return $this;
    }

    public function getPassword()
    {
        return $this->_password;
    }

    public function setPasswordSalt($text)
    {
        $this->_passwordSalt = (string) $text;
        return $this;
    }

    public function getPasswordSalt()
    {
        return $this->_passwordSalt;
    }

    public function setUsername($text)
    {
        $this->_username = (string) $text;
        return $this;
    }

    public function getUsername()
    {
        return $this->_username;
    }

    public function setRealName($text)
    {
        $this->_realName = (string) $text;
        return $this;
    }

    public function getRealName()
    {
        return $this->_realName;
    }

    public function setEmail($text)
    {
        $this->_email = (string) $text;
        return $this;
    }

    public function getEmail()
    {
        return $this->_email;
    }

    public function setId($id)
    {
        $this->_id = (int) $id;
        return $this;
    }

    public function getId()
    {
        return $this->_id;
    }

    public function setPasswordReset(Application_Model_UserPasswordReset $obj)
    {
        $this->_passwordReset = (object) $obj;
        return $this;
    }
    
    public function hasPasswordReset()
    {
        return !empty($this->_passwordReset);
    }
    
    public function getPasswordReset()
    {
        return $this->_passwordReset;
    }
    
    public function getResetHash()
    {
        if ($this->hasPasswordReset()) {
            return $this->_passwordReset->getResetId();
        }
        
        return null;
    }
    
    public function toArray()
    {
        return array(
            'id' => $this->_id,
            'email' => $this->_email,
            'password' => $this->_password,
            'username' => $this->_username,
            'password_salt' => $this->_passwordSalt,
            'real_name' => $this->_realName
        );
    }
}

